<template>
{{#if ctrl.psSysPFPlugin}}
    {{> @macro/plugins/widget/widget-use.hbs appPlugin=ctrl.psSysPFPlugin}}
{{else}}
    <div :class="classNames" {{#if ctrl.width}}:style="{width: {{> @macro/common/size.hbs width=ctrl.width}} }"{{/if}}>
        <AppDrbar :counterData="store.counterData" :ctrlItems="store.ctrlItems" :caption="model.caption" :codeName="model.codeName" @itemClick="(item:any) => { handleSelectChange(item) }">
            <AppIconText :text="model.caption" {{#if ctrl.editItemPSSysImage.cssClass}}iconClass="{{ctrl.editItemPSSysImage.cssClass}}"{{/if}}{{#if ctrl.editItemPSSysImage.imagePath}}imgPath="{{ctrl.editItemPSSysImage.imagePath}}"{{/if}}></AppIconText>
        </AppDrbar>
    </div>
{{/if}}
</template>
<script setup lang="ts">
// 基于template/src/widgets/\{{appEntities}}/\{{ctrls@DRBAR}}-drbar/\{{spinalCase ctrl.codeName}}-drbar.vue.hbs生成
{{> @macro/plugins/widget/widget-import.hbs ctrl=ctrl}}
import { AppDrbar } from "@components/widgets/drbar";
import { model } from "./{{spinalCase ctrl.codeName}}-drbar-model";
import { IContext, IParam, DrbarController, DrbarActionType, IDrbarAbility, IDrbarControllerParams, IDrbarStore, IDrbarController, ICtrlDataAction, ILoadingHelper, createUUID, IViewCtx } from "@/core";
import { getCtrlClassNames, useEventBind, useNavParamsBind } from "@/hooks/use-ctrl";

{{> @macro/widgets/ctrl/ctrl-props.hbs
    props="openView?: Function;
    newView?: Function;
    actions?: ICtrlDataAction;
    "
}}

{{> @macro/common/emit.hbs name="ctrl" actionType="DrbarActionType" ability="IDrbarAbility"}}

//  部件样式名
const classNames = computed(() => {
    return getCtrlClassNames(model, props);
});
const controlID = 'id' + createUUID();
const params: IDrbarControllerParams<DrbarActionType, IDrbarAbility> = {
    name: props.name,
    model,
    evt,
    controlID,
    actions: props.actions,
    openView: props.openView,
    newView: props.newView,
    closeView: props.closeView,
    pLoadingHelper: props.pLoadingHelper,
    pViewCtx: props.pViewCtx,
    handler: (data: IDrbarStore) => { return reactive(data); }
};

{{> @macro/common/controller.hbs name="ctrl" IController="IDrbarController" store="IDrbarStore" ability="IDrbarAbility" controller="DrbarController"}}

const handleSelectChange = (item: IParam) => {
  controller.handleSelectChange(item);
}
</script>
